package tedu;

import java.sql.*;

public class Demo03 {
    public static void main(String[] args) throws SQLException {

        //获取连接
        Connection conn = DriverManager.getConnection(
                "jdbc:mysql://localhost:3306/empdb" +
                        "?characterEncoding=utf8" +
                        "&serverTimezone=Asia/Shanghai",
                "root","root");
        Statement s = conn.createStatement();
        ResultSet rs = s.executeQuery("select * from hero");
        while(rs.next()){
            int id = rs.getInt("id");
            String name= rs.getString("name");
            int money = rs.getInt("money");
            System.out.println(id+":"+name+":"+money);
        }
        conn.close();
    }
}
